//
//  SearchWorkmateCell.m
//  MyProject
//
//  Created by 石小强 on 2018/4/26.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "SearchWorkmateCell.h"

@implementation SearchWorkmateCell

- (void)setModel:(WorkmateModel *)model {
    _model = model;
    
    self.nameL.text = model.nickName;
    if (model.nickName && model.nickName.length > 0) {
        self.positionL.text = [NSString stringWithFormat:@"-%@", model.positionName];
    } else {
        self.positionL.text = model.positionName;
    }
    
    self.sureIV.hidden = model.hasAssurePassService ? NO : YES;
    self.yearL.text = [NSString stringWithFormat:@"已在职%@年 | 帮助过%@人", model.inServiceTime, model.helpedCount];
    self.addressL.text = model.companyName;
    self.scoreL.text = [NSString stringWithFormat:@"%.0f%@", [model.degreeOfSatisfaction floatValue]*100,@"%"];
    
    CAShapeLayer *layerBack = [[CAShapeLayer alloc]init];
    layerBack.lineWidth = 4;
    //圆环的颜色
    layerBack.strokeColor = UIColorFromRGB(0xE2F2F4).CGColor;
    //背景填充色
    layerBack.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    CGFloat radius = 22;
    //按照顺时针方向
    BOOL clockWise = true;
    //初始化一个路径
    UIBezierPath *pathBack = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22 , 22 ) radius:radius startAngle:0 endAngle:2*M_PI clockwise:clockWise];
    //             UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(78 , 78 - 1 ) radius:radius startAngle:(2*M_PI) endAngle:(_score/100.0*2)*M_PI clockwise:clockWise];
    layerBack.path = [pathBack CGPath];
    [self.scoreV.layer addSublayer:layerBack];
    
    
    CAShapeLayer *layer = [CAShapeLayer new];
    layer.lineWidth = 4;
    //圆环的颜色
    layer.strokeColor = UIColorFromRGB(0x42CDD9).CGColor;
    //背景填充色
    layer.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    
    //初始化一个路径
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22 , 22 ) radius:radius startAngle:3*M_PI_2 endAngle:([model.degreeOfSatisfaction floatValue]*2*M_PI+3*M_PI_2) clockwise:clockWise];
    layer.path = [path CGPath];
    [self.scoreV.layer addSublayer:layer];
}

- (void)setIncumbentModel:(IncumbentModel *)incumbentModel {
    _incumbentModel = incumbentModel;
    
    
    self.nameL.text = incumbentModel.nickName;
    if (incumbentModel.nickName && incumbentModel.nickName.length > 0) {
        self.positionL.text = [NSString stringWithFormat:@"-%@", incumbentModel.positionName];
    } else {
        self.positionL.text = incumbentModel.positionName;
    }
    
    
    self.sureIV.hidden = incumbentModel.hasAssurePassService ? NO : YES;
    self.yearL.text = [NSString stringWithFormat:@"已在职%@年 | 帮助过%@人", incumbentModel.inServiceTime, incumbentModel.helpedCount];
    self.addressL.text = incumbentModel.companyName;
    self.scoreL.text = [NSString stringWithFormat:@"%.0f%@", [incumbentModel.degreeOfSatisfaction floatValue]*100,@"%"];
    
    CAShapeLayer *layerBack = [[CAShapeLayer alloc]init];
    layerBack.lineWidth = 4;
    //圆环的颜色
    layerBack.strokeColor = UIColorFromRGB(0xE2F2F4).CGColor;
    //背景填充色
    layerBack.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    CGFloat radius = 22;
    //按照顺时针方向
    BOOL clockWise = true;
    //初始化一个路径
    UIBezierPath *pathBack = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22 , 22 ) radius:radius startAngle:0 endAngle:2*M_PI clockwise:clockWise];
    //             UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(78 , 78 - 1 ) radius:radius startAngle:(2*M_PI) endAngle:(_score/100.0*2)*M_PI clockwise:clockWise];
    layerBack.path = [pathBack CGPath];
    [self.scoreV.layer addSublayer:layerBack];
    
    
    CAShapeLayer *layer = [CAShapeLayer new];
    layer.lineWidth = 4;
    //圆环的颜色
    layer.strokeColor = UIColorFromRGB(0x42CDD9).CGColor;
    //背景填充色
    layer.fillColor = [UIColor clearColor].CGColor;
    //设置半径为10
    
    //初始化一个路径
    UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:CGPointMake(22 , 22 ) radius:radius startAngle:3*M_PI_2 endAngle:([incumbentModel.degreeOfSatisfaction floatValue]*2*M_PI+3*M_PI_2) clockwise:clockWise];
    layer.path = [path CGPath];
    [self.scoreV.layer addSublayer:layer];
}

@end
